package com.lixl.thread;

import java.util.concurrent.ArrayBlockingQueue;

public class SaleTicketsSync {
	
	static int ticket = 100;
	
	static ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(100);

	public static void main(String[] args) {

		SaleTicketsSync sts = new SaleTicketsSync();
		
		for (int i = 0; i < 150; i++) {
			sts.new Window().start();
		}
		
		while(true){
			
		}
		
		
	}
	
	class Window extends Thread{
		
		@Override
		public void run() {
			//synchronized (this) {
				if(ticket>0){
					int s = ticket--;
					queue.add(s);
				}
			//}
		}
		
	}

}
